<?php

class Core_Component_System_Event_Request{
    
    public function afterInitialize(){
        $langCode = App::getRunningWebsite()->getLang();
        $GLOBALS[RC]->setLanguageCode($langCode);
        $langs = array();
        $langFiles = Soul_Util_FS::getFiles(DP_LANG.$langCode, 'yml');
        foreach($langFiles as $file){
            $langs[$file['name']] = Soul_Util_Yaml::parseFile($file['filename']);
        }
        Soul_Language_Translator::$languages = $langs;
        unset($langs);

        $model = App::getModel('system/localize')
                    ->loadBy(array('lang_code'=>$langCode));
        Soul_Language_Config::$shortDateFormat = $model->getShortDate();
        Soul_Language_Config::$longDateFormat = $model->getLongDate();
        Soul_Language_Config::$shortFullDateFormat = $model->getShortFullDate();
        Soul_Language_Config::$longFullDateFormat = $model->getLongFullDate();
    }
    
    public function beforeOutput(){
        $content = App::getBusiness('system/localize')->replaceLangTag($GLOBALS[RC]->getResponse()->getContent());
        $GLOBALS[RC]->getResponse()->setContent($content);
    }
}